package osSRC.banker;

import osSRC.Format;

import java.util.Scanner;

public class Main {
	static Scanner scanner=new Scanner(System.in);
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		open=false;
		Banker banker,banker_request,banker_safe;
		Request request;
		banker=new Banker("C:\\Users\\Lenovo\\IdeaProjects\\OS\\src\\osSrc\\Banker\\banker.txt");
		if(!open)return;
		while (true) {
			switch (showMenu()){
				case 1:
					banker_safe=new Banker(banker);
					if(banker_safe.safe())
						System.out.println("System status: safe");
					else System.out.println("System status: unsafe");
					System.out.println();
					break;
				case 2:
					banker_request=new Banker(banker);
					request=new Request(banker_request);
					if(banker_request.acceptRequest(request)) {
						if(banker_request.safe())
							System.out.println("System status: safe");
						else System.out.println("System status: unsafe");
						System.out.println();
					}
					break;
				case 3:
					System.out.println("Welcome to use again");
					return;
			}
			System.gc();
		}
	}

	public static boolean open;
	private final static String[] choices={
			"1. judge sys security",
			"2. judge request security",
			"3. exit"
	};
	private static int showMenu(){
		int res;
		for (String choice : Main.choices) {
			System.out.println(choice);
		}
		res= Format.getInt("",scanner);
		return res;
	}
}

